﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Dapper_Core.BLL.Impl;
using Dapper_Core.Common;
using Dapper_Core.DAL.Impl;
using Dapper_Core.Model;
using Dapper_Core.Table;
using Microsoft.AspNetCore.Mvc;

namespace Dapper_Core.Web.Areas.Workflow.Controllers
{
    public class WorkflowRecordController : Controller
    {
        public IActionResult Index()
        {
            return View();
        }

        public IActionResult GetWorkflowRecordByWorkflowTypeId(string workflowTypeId)
        {
            try
            {
                Expression<Func<V_WorkflowRecord, bool>> exp = workflowRecord => workflowRecord.WorkflowTypeId == workflowTypeId;
                List<V_WorkflowRecord> lstRecord = new V_WorkflowRecordBusiness().GetList(exp, false, "CreateDate asc").ToList();
                return Json(lstRecord);
            }
            catch (Exception ex)
            {
                NlogUtility.WriteError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, "GetWorkflowRecordByWorkflowTypeId()执行失败", $"workflowTypeId={workflowTypeId}", ex, "DapperCore");
                return Json(new List<V_WorkflowRecord>());
            }
        }
    }
}